$.ajax({
  type : 'POST',
  data : {
    username: username, password: password
  },
  xhrFields: {
    withCredentials: true,
  },
  url : "http://localhost:8888/user/login",
  dataType : 'json',
  success : function(data){
    console.log(data);
    window.location.href = "index.html";
  }
});
